package com.polaris.live.dialog

import android.content.Context
import com.lxj.xpopup.core.CenterPopupView
import com.polaris.live.R
import com.polaris.live.common.ext.setOnSingleClickListener
import com.polaris.live.databinding.DialogToolSureBinding
import com.polaris.live.im.sfs.bean.live.ext.UserBasicVo
import com.polaris.live.widget.avatar.FrameImageUtils

/**
 * ToolSureDialog 道具使用确认
 *
 * @author Created by 天晴 on 2024/7/27/016 19:40
 */
class ToolSureDialog(
    context: Context,
    val userBasicResp: UserBasicVo,
    val tips: String,
    private val mOK: (() -> Unit)? = null,
) : CenterPopupView(context) {
    override fun getImplLayoutId(): Int {
        return R.layout.dialog_tool_sure
    }

    private lateinit var mBinding: DialogToolSureBinding

    override fun onCreate() {
        super.onCreate()
        mBinding = DialogToolSureBinding.bind(popupImplView)
        mBinding.tvQx.setOnSingleClickListener {
            dismiss()
        }
        mBinding.tvConfirm.setOnSingleClickListener {
            dismiss()
            mOK?.invoke()
        }
        mBinding.avFv.setFrameImage(FrameImageUtils.urlToFrameImageBean(userBasicResp.avatarFrame))
        mBinding.ivUserHead.setImageUrl(userBasicResp.avatar, userBasicResp.userId)
        mBinding.tvName.text = userBasicResp.nickname
        mBinding.tvDetail.text = tips
    }
}